<%@page import="models.OrderProductModel"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.util.Map"%>
<%@page import="admin.data.CoordinaData"%>
<%@page import="java.util.TreeMap"%>
<%@page import="models.OrderModel"%>
<%@page import="java.util.List"%>
<%@page import="models.StaffModel"%>
<%@page import="models.RouteModel"%>
<%@page import="models.CoordinaModel"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	CoordinaModel coordinaModel = (CoordinaModel) request.getAttribute("coordinaModel");
	StaffModel staff = (StaffModel) request.getAttribute("staff");
	TreeMap<String, OrderProductModel> mapOrderProduct = (TreeMap<String, OrderProductModel>) request.getAttribute("mapOrderProduct");
	TreeMap<String, Integer> mapProductReturn = (TreeMap<String, Integer>) request.getAttribute("mapProductReturn");
	int totalVC = (Integer) request.getAttribute("totalVC");
	int totalSP = (Integer) request.getAttribute("totalSP");
	SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy");
%>

<jsp:include page="/admin/layouts/header.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>
        <div class="maincontent noright">
        	<div class="maincontentinner">
            	
                <ul class="maintabmenu">
                	<li class="current"><a href="/admin/store-item/import/">Trả hàng theo LOC</a></li>
                </ul><!--maintabmenu-->
                
                <div class="content">
                	<jsp:include page="/admin/elements/message.jsp"/>
                	<div class="contenttitle radiusbottom0">
	                	<h2 class="table"><span>Danh sách hàng trả về</span></h2>
	                </div> 	                
               		<br />
               			<div>
               				<p>Tên giao nhận: <b>[<%=coordinaModel.getEmployeeId() %>] <%=staff.getName()%></b></p>
               				<p>Ngày giao: <b><%=formatDate.format(coordinaModel.getCreated()) %></b></p>
               				<p>Mã tuyến: <b><%=coordinaModel.getId() %></b></p>               				
               			</div>
               		<br />
                    <% if(totalVC>0) { %>
	                <table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-table">
	                    <colgroup>
	                        <col class="con0">
	                        <col class="con1">
	                        <col class="con0">
	                    </colgroup>
	                    <thead>
	                        <tr>
	                        	<th class="head0">STT</th>
	                            <th class="head1" width="60%">Tên phiếu</th>
	                            <th class="head0">SL cần giao</th>
	                            <th class="head1">SL thực giao</th>	                           
	                            <th class="head0">SL trả về</th>	
	                        </tr>
	                    </thead>
	                    <tbody>
	                    	<% 
	                    		int i = 1;
                                for (Map.Entry<String, OrderProductModel> entry : mapOrderProduct.entrySet()) { 
                                     if((entry.getValue().getStoreType()==0)) { 
                            %>  
	                    	<tr>
                                <td align="center"><%=i %></td>
                                <td align="left">[<%=entry.getValue().getProductId() %>]<%=entry.getValue().getName() %></td>
                                <td align="center"><%=entry.getValue().getQuantity() %></td>
 								<td align="center"><%=entry.getValue().getProductDelivered() %></td>
                                <td align="center"><%=entry.getValue().getProductReturn() %></td>
                            </tr>
			                <% } if(entry.getValue().getStoreType()==0) {i++;} } %>                                      
	                    </tbody>
	                </table>
	                <% } %>	
	                <br /><br />
                    <% if(totalSP>0) { %>
	                <table cellspacing="0" cellpadding="0" border="0" class="stdtable stdtablecb" id="list-table">
	                    <colgroup>
	                        <col class="con0">
	                        <col class="con1">
	                        <col class="con0">
	                    </colgroup>
	                    <thead>
	                        <tr>
	                        	<th class="head0">STT</th>
	                            <th class="head1" width="60%">Tên sản phẩm</th>
	                            <th class="head0">SL cần giao</th>
	                            <th class="head1">SL thực giao</th>	                           
	                            <th class="head0">SL trả về</th>	
	                        </tr>
	                    </thead>
	                    <tbody>
	                    	<% 
	                    		int j = 1;
                                for (Map.Entry<String, OrderProductModel> entry : mapOrderProduct.entrySet()) { 
                                     if((entry.getValue().getStoreType()==1)) { 
                            %>  
	                    	<tr>
                                <td align="center"><%=j %></td>
                                <td align="left">[<%=entry.getValue().getProductId() %>]<%=entry.getValue().getName() %></td>
                                <td align="center"><%=entry.getValue().getQuantity() %></td>
                                <td align="center"><%=entry.getValue().getProductDelivered() %></td>
                                <td align="center"><%=entry.getValue().getProductReturn() %></td>
                            </tr>
			                <% } if(entry.getValue().getStoreType()==0) {j++;} } %>                                      
	                    </tbody>
	                </table>
	                <% } %>   
	                <br  clear="all"/><br />	                
	                <form class="stdform" action="/admin/store-item/import/" method="post">               		
               			<p align="right">
               				<input type="hidden" class="smallinput" name="coordinaId" value="<%=coordinaModel.getId() %>">   
               				<input type="hidden" class="smallinput" name="action" value="saveImport">	                           
                            <button class="radius3 apply-change">Submit</button>               
               			</p>                   	
               		</form>     
                </div><!--content-->             
            </div><!--maincontentinner-->
            
            <jsp:include page="/admin/elements/copyright.jsp">
            	<jsp:param name="language" value="1" />
			</jsp:include>
            
        </div><!--maincontent-->
        
<jsp:include page="/admin/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>